//
// Created by yaozi on 2019/11/16.
//
#include "HuffmanTree.h"
#include "HuffmanCode.h"
#include <sstream>
#include <cstring>
#include <map>

#ifndef HUFFMANTREE_IMPLEASE_H
#define HUFFMANTREE_IMPLEASE_H

#define LEN_CODE sizeof(HuffmanCode)
#define MAX_WEIGHT  2000
#define NODE_SIZE 4
#define TREE_SIZE (2*NODE_SIZE - 1)


void createHuffmanTree(int *weights, int nodeSize, HuffmanTree *huffmanTree);

void createHuffmanTree(int *weights, HuffmanTree *huffmanTree);

// 打印哈夫曼树
void printHuffmanTree(HuffmanTree *huffmanTree);

void printHuffmanCode(HuffmanCode huffmanCode[]);

void encoding(char *codes, HuffmanTree *huffmanTree, HuffmanCode *huffmanCode);

void encoding(char *codes, HuffmanTree *huffmanTree, int nodeSize, HuffmanCode *huffmanCode);

char overlapDecodingCore(int codes[], int codeLength, HuffmanTree root1, HuffmanTree huffmanTree[],
                         HuffmanCode huffmanCode[]);

void overlapDecoding(int codes[], int codeLength, HuffmanTree huffmanTree[], HuffmanCode huffmanCode[]);

void decoding(char *codes, HuffmanTree *huffmanTree, HuffmanCode *huffmanCode);

bool codeCheck(char codes[], map<string, char> _map);

string intToString(int &i);

#endif //HUFFMANTREE_IMPLEASE_H